package m1.RPC;

import m2.connector.Connector;

public class RPC extends Connector{
	
	private static RPC rpc = null;
	
	private RPC(){
		addGlueIn(new RPCGlue());
		addGlueOut(new RPCGlue());
		CallerClientRPC callerClientRPC = new CallerClientRPC();
		CalleeServerRPC calleeServerRPC = new CalleeServerRPC();
		CalleeClientRPC calleeClientRPC = new CalleeClientRPC();
		CallerServerRPC callerServerRPC = new CallerServerRPC();
		
		addProvidedRole(calleeClientRPC, calleeServerRPC);
		addRequiredRole(callerClientRPC, callerServerRPC);
		
		((RPCGlue)getGlueIn()).rpcConnectRequiredRoleToProvidedRole(callerClientRPC, calleeServerRPC);
		((RPCGlue)getGlueOut()).rpcConnectRequiredRoleToProvidedRole(callerServerRPC, calleeClientRPC);				
	}
	
	/**
	 * 
	 * @return
	 */
	public static RPC getInstance(){
		if (rpc == null){
			rpc = new RPC();
		}
		return rpc;
	}
}
